
"""
    flaskcms.extensions
    ~~~~~~~~~~~~~~~~~~
    扩展初始化
"""
from sqlalchemy import MetaData
from flask_sqlalchemy import SQLAlchemy
#from flask_caching import Cache
from flask_wtf.csrf import CSRFProtect
from flask_jwt_extended import JWTManager
from flask_session import Session as FLASK_SESSON
from flask_restful import Api
#from flask_uploads import UploadSet, IMAGES
from flask_cors import CORS


# Database

convention = {
    "ix": 'ix_%(column_0_label)s',
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(constraint_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s"
}
metadata = MetaData(naming_convention=convention)
db = SQLAlchemy(metadata=metadata)

#db = SQLAlchemy()
jwt = JWTManager()


# CSRF
csrf = CSRFProtect()
#flask-session
flasksess = FLASK_SESSON()
#aimages = UploadSet('aimages')

api = Api()
cors = CORS()
